//
//  TitleBtn.swift
//  CJPWB
//
//  Created by 陈锦彭 on 16/3/14.
//  Copyright © 2016年 chenjinpeng. All rights reserved.
//

import UIKit

class TitleBtn: UIButton {
    ///重写构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        setImage(UIImage(named: "navigationbar_arrow_down"), forState: .Normal)
        setImage(UIImage(named: "navigationbar_arrow_up"), forState: .Selected)
        setTitleColor(UIColor.blackColor(), forState: .Normal)
        setTitleColor(UIColor.redColor(), forState: .Selected)
        sizeToFit()
    }
    //如果重写一个构造函数,这个构造函数有required修饰的话,要写如下方法
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    ///设置按钮图片和文字的位置
    override func layoutSubviews() {
        super.layoutSubviews()
        titleLabel?.frame.origin.x = 0
        imageView?.frame.origin.x = (titleLabel?.frame.width)! + 10
    }

}
